import request from '../utils/request'

export function problemRelease (problem) {
  return request({
    url: '/problem/',
    method: 'POST',
    data: problem
  })
}

/**
 * 运行测试样例
 * @param runnerDto 测试样例
 */
export function problemRunTest (runnerDto) {
  return request({
    url: '/problem/run/test',
    method: 'get',
    params: runnerDto
  })
}
/**
 * 测试代码
 * @param runnerDto 测试的代码信息
 */
export function problemRunUserCode (runnerDto) {
  return request({
    url: '/problem/run/code',
    method: 'post',
    params: runnerDto
  })
}

/**
 * 保存代码
 * @param codeRunMsg
 */
export function problemSaveTestCode (codeRunMsg) {
  return request({
    url: '/problem/test/code',
    method: 'post',
    data: codeRunMsg
  })
}

/**
 * 保存测试用例
 * @param testInOutDto 测试用例
 */
export function problemSaveTestCase (testInOutDto) {
  return request({
    url: '/problem/test/case',
    method: 'post',
    data: testInOutDto
  })
}

export function problemSaveTestSample (testInOutDto) {
  return request({
    url: '/problem/test/sample',
    method: 'post',
    data: testInOutDto
  })
}

export function problemList (query) {
  return request({
    url: '/problem/',
    method: 'get',
    params: query
  })
}

export function problemById (id) {
  return request({
    url: `/problem/${id}`,
    method: 'get'
  })
}
